package com.kvn.backdoor.common;

/**
 * 异常码区段：[1001-1999]
* @author wzy
* @date 2017年6月20日 上午11:59:32
*/
public enum BackdoorErrorCode implements IErrors {
	CREATE_FILE_ERROR(1001, "创建文件[%s]失败"),
	DB_CONFIG_ISNULL(1002, "请先选择数据源"),
	ID_ISNULL(1003, "id为空"),
	DATA_NOT_EXIST(1004, "不存在id为[%s]的记录"),
	/**-----------------COMMON ERROR--------------------*/
	ILLEGAL_PARAM(1999, "参数异常:%s");
	
	
	private int code;
	private String msg;
	
	private BackdoorErrorCode(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}


	@Override
	public BackdoorException exp() {
		return new BackdoorException(code, msg);
	}

	@Override
	public BackdoorException exp(Object... args) {
		return new BackdoorException(code, String.format(msg, args));
	}

	@Override
	public BackdoorException exp(Throwable cause, Object... args) {
		return new BackdoorException(code, String.format(msg, args), cause);
	}

	@Override
	public BackdoorException expMsg(String message, Object... args) {
		return new BackdoorException(code, String.format(message, args));
	}

	@Override
	public BackdoorException expMsg(String message, Throwable cause, Object... args) {
		return new BackdoorException(code, String.format(message, args), cause);
	}
	
}
